<template>

<div id="app">
  <transition name="fade" mode="out-in">
    <keep-alive :max="10" >
      <component :is="coms[currentIndex]" />
    </keep-alive>
  </transition>
  <div class="bottom">
          <span :class="{active: currentIndex == index }" v-for="(item,index) in botArr" @click="handleClickBot(index)" :key="index">{{item}}</span>
  </div>
</div>

</template>

<script>
  import Home from './components/Home.vue';
  import Order from './components/Order.vue';
  import Mine from './components/Mine.vue';
  import Baobao from './components/BaoBao.vue';
export default {
  data(){
      return {
          botArr:["首页","爆爆团","订单","我的"],
          currentIndex: 0,
          coms:['Home','Baobao','Order','Mine']
      }
  },
  methods:{
      handleClickBot(index){
          this.currentIndex = index;
      }
  },
  components: {
      Home,
      Order,
      Mine,
      Baobao
      }
};
</script>

<style lang="scss" >
*{
  margin: 0;
  padding: 0;
}
#app{
  width: 100%;
}
.bottom {
  width: 95%;
  height: 40px;
  position: fixed;
  text-align: center;
  padding: 10px;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  border-top: 1px solid #f5f5f5;
  box-shadow: 0px -5px 10px #999;
  align-items: center;
  background: #f5f5f5;

}
.bottom span{
  width: 25%;
}
.active{
  color:orangered;
  font-size: 20px;
}
.fade-enter {
  
  opacity: 0;
}
.fade-enter-active {
  transition: all .3s;
}
.fade-enter-to {
  
  opacity: 1;
}

.fade-leave {
  
  opacity: 1;
}
.fade-leave-active {
  transition: all .3s;
}
.fade-leave-to {
  
  opacity: 0;
}
</style>